♻️ Rewrite session storage with CookieAccessor and native Web Locks#4252
Draft
thomas-lebeau wants to merge 5 commits intothomas.lebeau/v7-simplify-session-managersfrom
Draft
Conversation
- Remove sessionStoreOperations and its cookie-based lock mechanism - Introduce sessionLock module using navigator.locks for concurrency - Simplify sessionStore by inlining retrieve/persist logic within lock - Remove isLockEnabled from SessionStoreStrategy interface - Clean up related tests and fake session store strategy
The cookieObservable only depends on browser-core types and will be needed by the session cookie strategy in core. Move it to core and re-export from rum-core to keep existing imports working.
Introduce a CookieAccessor interface that abstracts cookie operations. Uses the CookieStore API when available for async native cookie access, and falls back to document.cookie with Promise wrappers. Also add set() and delete() to the CookieStore type definition.
Make the SessionStoreStrategy interface async (methods return Promises) to support the CookieStore API which is inherently asynchronous. Key changes: - SessionStoreStrategy methods return Promises - sessionLock supports async callbacks with promise-chain fallback when navigator.locks is unavailable - sessionStore lock callbacks are async, expire() runs inside lock - Replace polling-based session watching with onExternalChange: cookie strategy uses CookieStore events or interval polling, localStorage strategy uses native storage events - Cookie strategy uses CookieAccessor for read/write operations - All test suites updated with flushLock() async drain pattern
|
All contributors have signed the CLA ✍️ ✅ |
Bundles Sizes Evolution
🚀 CPU Performance
🧠 Memory Performance
|
|
✨ Fix all issues with BitsAI or with Cursor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The session management layer had accumulated complexity: custom cookie locking logic, duplicated session managers across packages (rum, logs), tightly coupled session store strategies, and synchronous cookie access patterns. This PR rewrites the session storage stack to be simpler, more robust, and aligned with v7 goals.
Changes
CookieAccessorabstraction layer that decouples session logic from raw cookie I/OSessionStoreStrategyfully async with event-driven change detection instead of pollingcookieObservablefrom rum-core to core for proper shared ownershiprumSessionManagerandlogsSessionManagerinto a single coreSessionManagerTrackedSessionintoSessionContext, extractSessionReplayStateandcomputeSessionReplayStatecomputeSessionReplayStatepostStartStrategyTest instructions
yarn test:unit— all unit tests should passyarn test:e2e— session store and tracking consent scenarios updatedChecklist